from driver import ADC
import utime as time


adc0 = ADC()
adc1=ADC()
adc3=ADC()
adc0.open("ADC0")
adc1.open("ADC1")
adc3.open("ADC3")

#AI1、AI2被测电流，范围4~20mA
def get_ai_current_value():
    value1="%.4f" %(adc0.readVoltage()/59000)
    value2="%.4f" %(adc1.readVoltage()/59000)
    print("current value of ai:",value1,value2)    
    return float(value1),float(value2)


#获取供电电压
def get_sys_vol():
    #供电电压（V） = （检测电压（uV）/1000000）*34
    value3 = "%.4f" %((adc3.readVoltage()/1000000)*34)
    return value3




if __name__ == '__main__':
    while True:
        time.sleep(1)
        a0,a1 = get_ai_current_value()
        a3 = get_sys_vol()
        print("AI1:{},AI2:{},vol:{}".format(a0,a1,a3))